package com.czt.mail.kafka.listener;

import com.alibaba.fastjson.JSON;
import com.czt.mail.kafka.entity.User;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

/**
 * @author czt
 * @version 1.0
 * {@desc}
 * @date 2024/10/8 18:36
 */
@Component
public class HelloListener {

    @KafkaListener(topics = "czt-topic")
    public void onMessage(String message) {
        if (!StringUtils.isEmpty(message)) {
            User user = JSON.parseObject(message, User.class);
            System.out.println("user = " + user);
            //System.out.println("message = " + message);
        }
    }
}
